/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tomasio.projects.welcome;

import com.tomasio.projects.welcome.dao.CartaoDAO;
import com.tomasio.projects.welcome.dao.DAOFactory;
import com.tomasio.projects.welcome.dto.CartaoDTO;
import com.tomasio.projects.welcome.interfaces.CartaoService;
import com.tomasio.projects.welcome.util.DAOUtil;
import java.util.List;

/**
 *
 * @author administrador
 */
public class SimpleCartaoService implements CartaoService {

    private DAOFactory factory = DAOUtil.getDAOFactory();

    @Override
    public void createCartao(CartaoDTO cartao) {
        CartaoDAO dao = factory.getCartaoDAO();
        dao.create(cartao);
    }

    @Override
    public void removeCartao(Long cartaoId) {
        CartaoDAO dao = factory.getCartaoDAO();
        dao.remove(cartaoId);
    }

    @Override
    public CartaoDTO findCartao(Long cartaoId) {
        CartaoDAO dao = factory.getCartaoDAO();
        return dao.find(cartaoId);
    }

    @Override
    public CartaoDTO findCartaoByNumero(String numero) {
        CartaoDAO dao = factory.getCartaoDAO();
        return dao.findByNumero(numero);
    }

    @Override
    public List<CartaoDTO> findAllCartoes() {
        CartaoDAO dao = factory.getCartaoDAO();
        return dao.findAll();
    }

    @Override
    public void updateCartao(CartaoDTO cartao) {
        CartaoDAO dao = factory.getCartaoDAO();
        dao.update(cartao);
    }
}
